﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Buildings.aspx.cs" Inherits="TeamPrasioliteWarGame.UnitsView" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Construct New Buildings</legend>
        <asp:ListView runat="server" ID="AllBuldingsView" ItemType="TeamPrasioliteWarGame.Models.Building">
            <LayoutTemplate>
                <table class="table-striped table-hover table table-bordered table-contents">
                    <thead>
                        <tr>
                            <th>Type</th>
                            <th>Required Wood</th>
                            <th>Required Iron</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                    </tbody>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td><%#: Item.Type %></td>
                    <td class="wood"><%#: Item.WoodCost %></td>
                    <td class="iron"><%#: Item.IronCost %></td>
                    <td>
                        <asp:LinkButton runat="server" ID="BuildLabel" Text="Build" CommandName="CreateBuilding"
                                        CommandArgument="<%#: Item.Id %>" OnCommand="CreateBuilding_Command"
                                        CssClass="btn btn-success" />
                    </td>
                </tr>
            </ItemTemplate>
            <EmptyDataTemplate>
                <tr>
                    <td colspan="4">There're no available buildings!</td>
                </tr>
            </EmptyDataTemplate>
        </asp:ListView>
    </fieldset>

    <fieldset>
        <legend>Your Buildings</legend>
        <asp:ListView runat="server" ID="UserBuildingsView" ItemType="TeamPrasioliteWarGame.Models.UserBuilding">
            <LayoutTemplate>
                <table class="table-striped table-hover table table-bordered table-contents">
                    <thead>
                        <tr>
                            <th>Type</th>
                            <th>Required Wood</th>
                            <th>Required Iron</th>
                            <th>Building Level</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
                    </tbody>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    <td><%#: Item.Building.Type %></td>
                    <td class="wood"><%#: (int)(Item.Building.WoodCost * Math.Pow(1.267, Item.BuildingLevel)) %></td>
                    <td class="iron"><%#: (int)(Item.Building.IronCost * Math.Pow(1.267, Item.BuildingLevel)) %></td>
                    <td><%#: Item.BuildingLevel %></td>
                    <td>
                        <asp:LinkButton runat="server" ID="UpgdareLabel" Text="Upgrade" CommandName="UpgradeBuilding"
                                        CommandArgument="<%#: Item.BuildingId %>"
                                        OnCommand="UpgradeBuilding_Command"
                                        CssClass="btn btn-success" />
                    </td>
                </tr>
            </ItemTemplate>
            <EmptyDataTemplate>
                <tr>
                    <td colspan="5">You dont have any buildings yet!</td>
                </tr>
            </EmptyDataTemplate>
        </asp:ListView>
    </fieldset>
</asp:Content>
